package com.by.block;

import com.alibaba.csp.sentinel.slots.block.BlockException;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ServivE
 * @version 0.1
 * @className OrderBlockHandler
 * @description
 * @date 2024/11/1 10:10
 * @since jdk17
 */
public class OrderBlockHandler {
    /**
     * 限流后的逻辑
     * @param id
     * @param e
     * @return
     */
    public static Map queryFail(int id , BlockException e) {
        System.out.println("id===" + id);
        Map map = new HashMap();
        map.put("code", 0);
        map.put("msg", "服务器繁忙");
        return map;
    }

    /**
     * 异常处理
     * @param id
     * @param e
     * @return
     */
    public static Map handlerError(int id, Throwable e) {
        System.out.println("================fallback==========");
        Map map = new HashMap();
        map.put("code", 0);
        map.put("msg", "异常处理：" + e.getMessage());
        return map;
    }
}
